feat: add openai and claude structured output config#5763
Conversation
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
|
👋 Commands for maintainers:
|
|
Risk: 35/100 (low) SummaryAdds JSON Schema-constrained structured output support to both OpenAI and Claude text-prompt components, including shared validation/normalization logic, provider API wiring, frontend canvas badges, and a general autosave fix for togglable fields. Concerns
Recommended reviewers: forestileao |
…chema Addresses Cursor Bugbot review on PR superplanehq#5763: claude.textPrompt Setup only checked the schema root was an object, while the field description and docs require every object to set additionalProperties:false (an Anthropic requirement). Such schemas passed Setup and failed later at the Claude API, unlike openai.textPrompt which rejects them at Setup. Add validateClaudeOutputSchema: a recursive check that every object sets additionalProperties:false (walking properties, items, anyOf/allOf/oneOf, $defs). It intentionally does NOT require all properties in "required" — Anthropic permits optional fields, unlike OpenAI strict mode. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Set node-level metadata in Setup for claude.textPrompt and openai.textPrompt so the configured model, max tokens (Claude), and whether structured output is enabled are visible on the node in the UI without opening its config. Mirrors the existing node-metadata pattern (e.g. digitalocean IndexKB). Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Replace the raw JSON Schema input on claude.textPrompt and openai.textPrompt with a guided builder: users define output fields (name, type, description, required) including nested objects and lists, and the backend assembles the JSON Schema. Provider rules are handled automatically -- Anthropic omits optional fields from "required"; OpenAI strict mode lists every field and makes optional ones nullable. Shared logic lives in the new pkg/integrations/structuredoutput package. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Replace the guided field builder with a JSON Schema the user edits directly. The Structured Output field is now a togglable JSON text area pre-filled with an editable default schema, validated before the request is fired (valid JSON, a JSON object, object root with non-empty properties). The schema is normalized to provider constraints on send: every object gets additionalProperties:false, and OpenAI strict mode additionally forces all properties into required. Claude keeps required as written. Update both text prompt components, the node-metadata flag, the frontend mappers, and regenerate component docs. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Enabling a togglable field only stored its value in local state until a save-on-blur field type (e.g. a text field pre-filled with a default) was blurred. A run or reload before that persisted config without the value, so a component like the structured-output schema showed as enabled but was silently skipped. Trigger autosave on the off->on transition of a togglable field. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
The canvas node tile computed the badge as meta?.structuredOutput ?? hasSchema(config?.outputSchema), so a stale persisted metadata flag (autosave updates configuration only) kept the badge visible after structured output was cleared or disabled. Derive it from the live configuration instead, falling back to metadata only when no configuration is present. Also run prettier on SettingsTab.tsx so make check.format.js passes. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
The structured-output helpers build configuration fields and JSON schemas for integrations rather than being an integration themselves, so per review they do not belong under pkg/integrations. Move the package to pkg/configuration/structuredoutput (alongside the existing pkg/configuration/expressionvalidation helper) and update the claude and openai text prompt imports. Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e5f5900. Configure here.
The structured-output schema field supports expressions like the prompt field,
but Setup parsed the stored value as literal JSON, so a schema containing an
unresolved {{ ... }} expression failed config-time validation even though it
would resolve to valid JSON at execution. Skip JSON validation in Setup when the
schema still contains an expression; Execute re-parses the resolved value.
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
|
👍 |
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>

Summary
This adds structured output as a configuration option for the following components:
claude.textPromptopenai.textPrompt